/* 
 * File:   BRIC.h
 * Author: nata
 *
 * Created on March 13, 2012, 3:30 PM
 */

#ifndef BRIC_H
#define	BRIC_H

#include "Node.h"
#include "Image.h"
#include <opencv/cv.h>
#include <map>
#include <vector>

using namespace std;

class BRIC {
private:
    int width;
    int height;
    int alpha;
    int beta;
    int L;
    int use_score;
    
    double score2004(Node* root);
    double score2008(Node* root);
    double score2012(Node* root);
    double individualScore2008(Node* node, double occupiedArea, double relativeAreaSum);
    void generateTree(Node* root, Node* paramActual, Node* leaf, vector<Node* >* trees, Orientation orientation);
    void applyDimensions(Node* raiz, map<Node*, int>* mapa, CvMat* x, Orientation orientation);
    void calculateBissections(CvMat* A, CvMat* B, Node* raiz, map<Node*, int>* mapa, Orientation orientacaoSolucao);
    void calculateNode(CvMat* A, CvMat* B, Node* no, Node* raiz, map<Node*, int>* mapa, Orientation orientacaoSolucao, bool oposto);

public:
    BRIC(int width, int height, int alpha, int beta, int L);
    void mapear(Node* no, map<Node*, int>* mapa);
    double score(Node* root);
    Node* createTree(vector<Image*>* images);
    void solve(Node* root);
    void solve(Node* root, Orientation orientation);
    void generateTrees(Node* root, Node* paramActual, Node* leaf, vector<Node* >* trees);
    void set_score(int n);
    void fix(Node* root);
};

#endif	/* BRIC_H */

